package com.heima.wemedia.feign;

import com.heima.model.admin.dtos.AdSensitiveDto;
import com.heima.model.admin.dtos.AdSensitiveListDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.ISensitiveClient;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Franky
 * @version 1.0
 * @project heima-leadnews-shizhan
 * @description
 * @date 2023/9/17 10:10:19
 */
@RestController
public class SensitiveClient implements ISensitiveClient {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 根据id删除敏感词
     * @param id
     * @return {@link ResponseResult}
     */
    @Override
    @DeleteMapping("/api/v1/sensitive/del/{id}")
    public ResponseResult del(@PathVariable Integer id) {
        return wmSensitiveService.del(id);
    }

    /**
     * 查询敏感词列表
     * @param sensitiveListDto
     * @return {@link ResponseResult}
     */
    @Override
    @PostMapping("/api/v1/sensitive/list")
    public ResponseResult list(AdSensitiveListDto sensitiveListDto) {
        return wmSensitiveService.queryList(sensitiveListDto);
    }

    /**
     * 新增敏感词
     * @param sensitiveDto
     * @return {@link ResponseResult}
     */
    @Override
    @PostMapping("/api/v1/sensitive/save")
    public ResponseResult save(AdSensitiveDto sensitiveDto) {
        return wmSensitiveService.add(sensitiveDto);
    }

    /**
     *更新敏感词
     * @param sensitiveDto
     * @return {@link ResponseResult}
     */
    @PostMapping("/api/v1/sensitive/update")
    @Override
    public ResponseResult update(AdSensitiveDto sensitiveDto) {
        return wmSensitiveService.updateSensitive(sensitiveDto);
    }
}
